package com.dailycodebuffer.springbootmongodb.service;




import com.dailycodebuffer.springbootmongodb.collection.Category;
import com.dailycodebuffer.springbootmongodb.repository.CategoryRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;


/**
 * 业务层
 *
 * @author makejava
 * @since 2025-01-04 00:23:41
 */
@Service
public class CategoryServiceImpl implements CategoryService {

	@Resource
    private CategoryRepository categoryRepository;

    @Override
    public void save(Category category) {
        categoryRepository.save(category);
    }

    @Override
    public Category findById(Integer id) {
        return categoryRepository.findById(id).orElse(null);
    }

    @Override
    public Page<Category> list(Pageable page) {
        return categoryRepository.findAll(page);
    }

}

